<script>
    import Sidebar from "$lib/components/public/Sidebar.svelte";
    import RightBox from "$lib/components/public/RightBox.svelte";
    import {status} from "$lib/stores/globalControl.svelte.js";
    import {goto} from "$app/navigation";
    import {browser} from "$app/environment";
    import {localInfo} from "$lib/stores/Storage.svelte.js";
    import {seletedRoute} from "$lib/stores/globalControl.svelte.js";
    import {page} from "$app/state";

    if($localInfo?.length !== 0){
        status.set(false);  //$status 判断是不是独立页面
    }

    $effect(()=>{
        if(browser && $status){//登录了以后 不能在回到登录页面
            goto("/login");
        }
    })



</script>

{#if $status}
    <slot />
{:else}
    <div class="layout">
        <Sidebar></Sidebar>
        <RightBox>
            <slot />
        </RightBox>
    </div>
{/if}

<style>
    :global(*) {
        margin: 0;
        padding: 0;
    }
    .layout {
        display: flex;
        width: 100%;
        height: 100%;
        justify-content: flex-end;
        align-items: center;
    }
    /* 添加媒体查询 */
    @media (max-width: 768px) {
        .layout {
            flex-direction: column;
        }
    }
</style>


